package com.jy.framework.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jy.framework.sys.dao.SysDictDataDao;
import com.jy.framework.sys.entity.SysDictDataEntity;
import com.jy.framework.sys.service.SysDictDataService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("dictDataService")
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataDao, SysDictDataEntity> implements SysDictDataService {
    /**
     * 根据字典类型查询字典数据信息
     *
     * @param dictType 字典类型
     * @return 参数键值
     */
    @Override
    public List<SysDictDataEntity> selectDictDataByType(String dictType) {
        QueryWrapper<SysDictDataEntity> dict = new QueryWrapper<>();
        dict.lambda().eq(SysDictDataEntity::getType,dictType);
        List<SysDictDataEntity> dictDataEntities = list(dict);
        return dictDataEntities;
    }
    /**
     * 根据字典类型和字典键值查询字典数据信息
     *
     * @param dictType 字典类型
     * @param dictValue 字典键值
     * @return 字典标签
     */
    @Override
    public String selectDictLabel(String dictType, String dictValue) {
        QueryWrapper<SysDictDataEntity> dict = new QueryWrapper<>();
        dict.lambda().eq(SysDictDataEntity::getType,dictType).eq(SysDictDataEntity::getValue,dictValue);
        SysDictDataEntity one = getOne(dict);
        return one.getName();
    }
}
